package server.command.client;

import java.util.Set;

import common.messages.KVMessage.StatusType;
import utils.IKeyValueStorage;

public class CommandListKeys implements ICommand {
	private IKeyValueStorage storage;
	
	public CommandListKeys(IKeyValueStorage storage) {
		this.storage = storage;
	}
	
	@Override
	public String execute() {
		String keysList = "";
		Set keys = storage.getKeysSet();
		if(keys.size()==0) {
			keysList = "No keys";
		} else {
			for (Object key: keys) {
				keysList += key + ", ";
			}
		}
		return ClientInputHandler.composeClientResponse(StatusType.LIST_KEYS_SUCCESS, keysList, "");
	}
}
